package com.example.qxfw.tourqx.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.zy.SpecialFcst;
import com.example.qxfw.common.entity.zy.TourStations;
import com.example.qxfw.tourqx.service.JgybcxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "旅游气象-景观预报和景观预报查询")
@RestController
@CrossOrigin
@RequestMapping("/jgybcx")
public class JgybcxController {
    @Autowired
    private JgybcxService jgybcxService;

    @ApiOperation("预报地点")
    @GetMapping("/getPredictionSpot")
    public SysResult getPredictionSpot(){
        List<TourStations> list = jgybcxService.getPredictionSpot();
        return SysResult.success(list);
    }

    @ApiOperation("预报")
    @GetMapping("/getPrediction")
    public String[] getPrediction(String date, String ntime, String landscape, String spot, String name){
        String[] txt = jgybcxService.txt(date, ntime, landscape, spot, name);
        return txt;
    }

    @ApiOperation("景观预报查询")
    @GetMapping("/selectOfSpecialFcst")
    public SysResult selectOfSpecialFcst(String startTime, String endTime){
        List<SpecialFcst> list = jgybcxService.selectOfSpecialFcst(startTime, endTime);
        return SysResult.success(list);
    }

    @ApiOperation("预报查看")
    @GetMapping("/selectByIdOfSpecialFcst")
    public SysResult selectByIdOfSpecialFcst(String id){
        List<SpecialFcst> list = jgybcxService.selectByIdOfSpecialFcst(id);
        return SysResult.success(list);
    }

    @ApiOperation("景观预报查询保存按钮")
    @PutMapping("/save")
    public SysResult save(@RequestBody SpecialFcst specialFcst){
        SpecialFcst result = jgybcxService.save(specialFcst);
        if (result != null) {
            return SysResult.success(result);
        }else {
            return SysResult.fail("保存失败！！！");
        }
    }



}
